package application

import (
	"pdemo/bff/internal/infrastructure/server"

	"github.com/gorilla/mux"

	khttp "github.com/go-kratos/kratos/v2/transport/http"
)

type Context = khttp.Context

func PathParam(ctx Context, name string) (val string, ok bool) {
	raws := mux.Vars(ctx.Request())
	val, ok = raws[name]
	return
}

type RouterDefines struct {
	E *Example
}

func (rd *RouterDefines) RouteRegister(r *khttp.Router) {
	var H = server.HandlerFunc

	v1 := r.Group("/v1")
	{
		{
			v1.GET("/hello/{name}", H(rd.E.Hello))
			v1.GET("/add", H(rd.E.Add))
		}
	}
}
